fix(transaction-pay-controller): use Infura endpoint for live token balance queries#8839
Merged
Conversation
77eee8b to
a9de394
Compare
4c70b63 to
8350c8e
Compare
aa7c99a to
2b7b6e0
Compare
…rams with generic return type
…ting after rpcRequest refactor
…pe param name, unused import, unnecessary casts
2472294 to
4ca5364
Compare
OGPoyraz
approved these changes
Jun 1, 2026
pull Bot
pushed a commit
to dmrazzy/core
that referenced
this pull request
Jun 4, 2026
…MetaMask#8992) ## Explanation Add flag to exclude networks from using infura for live balance. It is needed primarily for Monad, related to PR: MetaMask#8839 ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [X] I've updated the test suite for new or updated code as appropriate - [X] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [X] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [X] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes which RPC endpoint validates live balances before pay quotes/submit; misconfigured flags could cause wrong or failed balance reads on affected chains. > > **Overview** > Adds remote feature flag **`confirmations_pay_extended.excludeChainIdsFromInfura`** so specific chains can opt out of preferring Infura for **live on-chain balance** RPCs (e.g. Monad). > > Introduces **`isChainExcludedFromInfura`** (case-insensitive chain ID match) and wires **`getLiveTokenBalance`** to pass **`preferInfura: false`** when the chain is listed, so balance queries use the default network client instead of forcing the Infura endpoint. Behavior is unchanged for chains not in the list. > > Unit tests cover the flag helper and Infura skip/use paths in live balance fetching; the package changelog documents the change. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit e244127. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
When querying a live on-chain token balance, the controller previously resolved the network client using
findNetworkClientIdByChainId, which returns whatever endpoint is currently selected for that chain — including custom RPC endpoints. Custom RPC endpoints may not support thependingblock tag used by these calls, causing the query to fail.This change adds a preference for the chain's Infura endpoint when one is configured, falling back to the existing
findNetworkClientIdByChainIdbehaviour if no Infura endpoint is configured or if the lookup throws.References
Checklist
Note
Medium Risk
Changes which RPC endpoint serves balance checks and on-chain amount reads before Relay submit; wrong endpoint selection could block or mis-validate pay deposits, though Infura preference falls back to the default client.
Overview
Introduces shared
providerutilities (getNetworkClientId,rpcRequest) so chain RPC calls go through the controller messenger’sprovider.requestinstead of ethersWeb3Provider/Contract.Live token balances (
getLiveTokenBalance) now calleth_getBalance/eth_callwith thependingblock tag and passpreferInfura: true, picking the chain’s InfuranetworkClientIdwhen configured and otherwise usingfindNetworkClientIdByChainId—addressing failures on custom RPCs that don’t support pending queries.The same RPC helper path is used for fiat source amount resolution and transfer amount from tx hash (receipt logs,
debug_traceTransaction,eth_getTransactionByHash). Across, Relay, and gas estimation call sites switch togetNetworkClientIdfor consistency.Messenger
AllowedActionsand test mocks registerNetworkController:getNetworkConfigurationByChainId. Changelog documents the Infura preference for live balance queries.Reviewed by Cursor Bugbot for commit 4ca5364. Bugbot is set up for automated code reviews on this repo. Configure here.